package com.atguigu.spzx.common.utils;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;

import java.util.List;

public class PageUtils {

    public static <T> Page<T> convertTo(Page page, Class<T> clazz){
        List records = page.getRecords();
        List<T> list = BeanUtils.toBeanList(records,clazz);
        page.setRecords(list);
        return page;
    }

    public static <T> PageInfo<T> convertToPageInfo(Page<T> page){
        PageInfo<T> pageInfo = new PageInfo<>();
        pageInfo.setList(page.getRecords());
        pageInfo.setTotal(page.getTotal());
        return pageInfo;
    }

}
